Public Class LabType

    Protected _lab_type_id As Integer
    Protected _lab_type_name As String
    Protected _Data As ArrayList
    Protected _DataCurrent As Integer

    Public Property lab_type_id() As Integer
        Get
            Return _lab_type_id
        End Get
        Set(ByVal value As Integer)
            _lab_type_id = value
        End Set
    End Property

    Public Property lab_type_name() As String
        Get
            Return _lab_type_name
        End Get
        Set(ByVal value As String)
            _lab_type_name = value
        End Set
    End Property

    Public Function getLabType() As System.Data.DataSet
        Dim decryptText As New DateUtilities.Encrypt_Data()
        Dim objConn As New MySql.Data.MySqlClient.MySqlConnection( _
            decryptText.getDecrypt(System.Configuration.ConfigurationManager.ConnectionStrings( _
            "PoliceHealthConnectionString").ToString(), True))
        Dim objCmd As New MySql.Data.MySqlClient.MySqlCommand()
        objCmd.Connection = objConn
        objCmd.CommandType = CommandType.StoredProcedure
        objCmd.CommandText = "proc_SELECT_Lab_Type"

        Dim objDa As New MySql.Data.MySqlClient.MySqlDataAdapter(objCmd)
        Dim objDs As New System.Data.DataSet()
        objDa.Fill(objDs, "LabType")

        Return objDs
    End Function

    Protected Function getsLabType() As ArrayList
        Dim outResult As New ArrayList()
        Dim decryptText As New DateUtilities.Encrypt_Data()
        Dim objConn As New MySql.Data.MySqlClient.MySqlConnection( _
            decryptText.getDecrypt(System.Configuration.ConfigurationManager.ConnectionStrings( _
            "PoliceHealthConnectionString").ToString(), True))
        Dim objCmd As New MySql.Data.MySqlClient.MySqlCommand()
        objCmd.Connection = objConn
        objCmd.CommandType = CommandType.StoredProcedure
        objCmd.CommandText = "proc_SELECT_Lab_Type"

        Dim objDa As New MySql.Data.MySqlClient.MySqlDataAdapter(objCmd)
        Dim objDs As New System.Data.DataSet()
        objDa.Fill(objDs, "LabType")

        For Each objDr As System.Data.DataRow In objDs.Tables("LabType").Rows
            Dim obj As LabType = New LabType()
            obj.lab_type_id = objDr.Item("lab_type_id").ToString()
            obj.lab_type_name = objDr.Item("lab_type_name").ToString()
            outResult.Add(obj)
        Next

        Return outResult
    End Function

    Public Function getMaxLabTypeID() As System.Data.DataSet
        Dim decryptText As New DateUtilities.Encrypt_Data()
        Dim objConn As New MySql.Data.MySqlClient.MySqlConnection( _
            decryptText.getDecrypt(System.Configuration.ConfigurationManager.ConnectionStrings( _
            "PoliceHealthConnectionString").ToString(), True))
        Dim objCmd As New MySql.Data.MySqlClient.MySqlCommand()
        objCmd.Connection = objConn
        objCmd.CommandType = CommandType.StoredProcedure
        objCmd.CommandText = "proc_SELECT_MaxLabTypeID"

        Dim objDa As New MySql.Data.MySqlClient.MySqlDataAdapter(objCmd)
        Dim objDs As New System.Data.DataSet()
        objDa.Fill(objDs, "MaxLabTypeID")

        Return objDs
    End Function

    Protected Function getsMaxLabTypeID() As ArrayList
        Dim outResult As New ArrayList()
        Dim decryptText As New DateUtilities.Encrypt_Data()
        Dim objConn As New MySql.Data.MySqlClient.MySqlConnection( _
            decryptText.getDecrypt(System.Configuration.ConfigurationManager.ConnectionStrings( _
            "PoliceHealthConnectionString").ToString(), True))
        Dim objCmd As New MySql.Data.MySqlClient.MySqlCommand()
        objCmd.Connection = objConn
        objCmd.CommandType = CommandType.StoredProcedure
        objCmd.CommandText = "proc_SELECT_MaxLabTypeID"

        Dim objDa As New MySql.Data.MySqlClient.MySqlDataAdapter(objCmd)
        Dim objDs As New System.Data.DataSet()
        objDa.Fill(objDs, "MaxLabTypeID")

        For Each objDr As System.Data.DataRow In objDs.Tables("MaxLabTypeID").Rows
            Dim obj As LabType = New LabType()
            obj.lab_type_id = objDr.Item("maxLabID").ToString()
            outResult.Add(obj)
        Next

        Return outResult
    End Function

    Public Function insertLabType() As Boolean
        Try
            Dim decryptText As New DateUtilities.Encrypt_Data()
            Dim objConn As New MySql.Data.MySqlClient.MySqlConnection( _
                decryptText.getDecrypt(System.Configuration.ConfigurationManager.ConnectionStrings( _
                "PoliceHealthConnectionString").ToString(), True))
            Dim objCmd As New MySql.Data.MySqlClient.MySqlCommand()
            objCmd.Connection = objConn
            objCmd.CommandType = CommandType.StoredProcedure
            objCmd.CommandText = "proc_INSERT_LabType"

            Dim objParam As New MySql.Data.MySqlClient.MySqlParameter("inLabTypeID", lab_type_id)
            objCmd.Parameters.Add(objParam)

            objParam = New MySql.Data.MySqlClient.MySqlParameter("inLabTypeName", lab_type_name)
            objCmd.Parameters.Add(objParam)

            objConn.Open()
            objCmd.ExecuteNonQuery()
            objConn.Close()

            Return True
        Catch ex As Exception
            Return False
        End Try
    End Function

    Public Function updateLabType() As Boolean
        Try
            Dim decryptText As New DateUtilities.Encrypt_Data()
            Dim objConn As New MySql.Data.MySqlClient.MySqlConnection( _
                decryptText.getDecrypt(System.Configuration.ConfigurationManager.ConnectionStrings( _
                "PoliceHealthConnectionString").ToString(), True))
            Dim objCmd As New MySql.Data.MySqlClient.MySqlCommand()
            objCmd.Connection = objConn
            objCmd.CommandType = CommandType.StoredProcedure
            objCmd.CommandText = "proc_UPDATE_LabType"

            Dim objParam As New MySql.Data.MySqlClient.MySqlParameter("inLabTypeID", lab_type_id)
            objCmd.Parameters.Add(objParam)

            objParam = New MySql.Data.MySqlClient.MySqlParameter("inLabTypeName", lab_type_name)
            objCmd.Parameters.Add(objParam)

            objConn.Open()
            objCmd.ExecuteNonQuery()
            objConn.Close()

            Return True
        Catch ex As Exception
            Return False
        End Try
    End Function

    Public Function deleteLabType() As Boolean
        Try
            Dim decryptText As New DateUtilities.Encrypt_Data()
            Dim objConn As New MySql.Data.MySqlClient.MySqlConnection( _
                decryptText.getDecrypt(System.Configuration.ConfigurationManager.ConnectionStrings( _
                "PoliceHealthConnectionString").ToString(), True))
            Dim objCmd As New MySql.Data.MySqlClient.MySqlCommand()
            objCmd.Connection = objConn
            objCmd.CommandType = CommandType.StoredProcedure
            objCmd.CommandText = "proc_DELETE_LabType"

            Dim objParam As New MySql.Data.MySqlClient.MySqlParameter("inLabTypeID", lab_type_id)
            objCmd.Parameters.Add(objParam)

            objConn.Open()
            objCmd.ExecuteNonQuery()
            objConn.Close()

            Return True
        Catch ex As Exception
            Return False
        End Try
    End Function

    Public Function NextRecord() As Boolean
        If ((Not _Data Is Nothing) AndAlso (((Not _Data Is Nothing) AndAlso _
            (_DataCurrent < _Data.Count And _Data.Count > 0)))) Then
            _lab_type_id = _Data(_DataCurrent).lab_type_id
            _lab_type_name = _Data(_DataCurrent).lab_type_name
            _DataCurrent += 1
            Return True
        End If
        Return False
    End Function

    Public Sub LoadLabType()
        _Data = New ArrayList
        _DataCurrent = 0
        _Data = getsLabType()
    End Sub

    Public Sub LoadMaxLabTypeID()
        _Data = New ArrayList
        _DataCurrent = 0
        _Data = getsMaxLabTypeID()
    End Sub

End Class
